package com.atguigu.staservice.controller;


import com.atguigu.commonutils.R;
import com.atguigu.staservice.client.UcenterClient;
import com.atguigu.staservice.entity.vo.SearchObjVo;
import com.atguigu.staservice.service.StatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author AIR
 * @since 2022-10-14
 */
@RestController
@RequestMapping("/staservice/sta")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService staService;

    //生成统计数据
    @PostMapping("registerCount/{day}")
    public R registerCount(@PathVariable String day){
        staService.registerCount(day);
        System.out.println(1);
        return R.ok();
    }

    //图标显示，返回两部分数据，日期json数组，数量json数组
    @PostMapping("showData")
    public R showData(@RequestBody SearchObjVo searchObjVo){
        Map<String,Object> map = staService.getShowData(searchObjVo);

        return R.ok().data(map);
    }

    //返回最近七天的数据 Nearly seven days
    @GetMapping("nearlySevenData")
    public R nearlySevenDays(){
        Map<String,Object> map = staService.getNearlySevenDays();
        System.out.println(map);
        return R.ok().data(map);
    }

    //返回前一天数据
    //Previous day
    @GetMapping("previousDayData")
    public R previousDayData(){
        Map<String,Object> map = staService.getPreviousDayData();
        return R.ok().data(map);
    }

}
